import { ipcMain } from "electron";
import { dialog } from "electron";
import fs from "fs";

async function selectFile(params) {
  const result = await dialog.showOpenDialog({
    properties: ["openFile"],
    filters: [{ name: "PDF Files", extensions: ["pdf"] }],
    title: "选择PDF文件",
  });
  if (!result.canceled && result.filePaths.length > 0) {
    return result.filePaths[0];
  }
  return null;
}

ipcMain.handle("select-file", selectFile);
